import { exportUrl, downloadTemplateUrl, getScanTypeList, getGoodsTypeList } from "@/api/review/mesScrapMaterial"

import { exportExcel } from "@/utils/judge"

// 列表头按钮配置
export const operateList = [
  {
    name: $i18n.t("common.export"),
    type: "primary",
    icon: "el-icon-download",
    handleName: "export", //点击时返回的标识
    url: exportUrl
    //auth: "auth:operlog:export", //权限字段
  }
]
// 行末按钮配置
export const rowConfig = [
  {
    name: $i18n.t("common.details"),
    type: "info",
    class: "row-btn-info",
    handleName: "detail" //点击时返回的标识
  }
]
// 搜索条件配置
export const searchConfig = {
  inline: true,
  formDesc: {
    reviewCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.reviewCode")
    },
    barcode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.barcode")
    },
    workshopName: {
      type: "input",
      label: $i18n.t("common.workshopName")
    },
    lineName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodLineName")
    },
    processName: {
      type: "input",
      label: $i18n.t("common.processName")
    },
    cellName: {
      type: "input",
      label: $i18n.t("common.workCellName")
    },
    teamName: {
      type: "input",
      label: $i18n.t("common.teamName")
    },
    shiftCode: {
      type: "input",
      label: $i18n.t("common.shiftCode")
    },
    scanTime: {
      type: "datetimerange",

      label: $i18n.t("mesScrapMaterial.scanTime"),
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        searchArrKey: ["scanTimeMin", "scanTimeMax"]
      }
    },
    planCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.planCode")
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.orderCode")
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.modelCode")
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.modelName")
    },
    equipmentCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.equipmentCode")
    },
    equipmentName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.equipmentName")
    },
    scanType: {
      type: "select",
      label: $i18n.t("mesScrapMaterial.scanType"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getScanTypeList()
        return list.data.result
      }
    },
    faultCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.faultCode")
    },
    faultName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.faultName")
    },
    goodsTypeKey: {
      type: "select",
      label: $i18n.t("mesScrapMaterial.goodsTypeKey"),
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getGoodsTypeList()
        return list.data.result
      }
    },
    reviewTime: {
      type: "datetimerange",

      label: $i18n.t("mesScrapMaterial.reviewTime"),
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss",
        searchArrKey: ["reviewTimeMin", "reviewTimeMax"]
      }
    }
  }
}
// 新增/删除表单配置
export const formDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    reviewCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.reviewCode"),
      layout: 12,
      required: false
    },
    barcode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.userScanBarCode"),
      layout: 12,
      required: false
    },
    workshopCode: {
      type: "input",
      label: $i18n.t("common.workshopCode"),
      layout: 12,
      required: false
    },
    workshopName: {
      type: "input",
      label: $i18n.t("common.workshopName"),
      layout: 12,
      required: false
    },
    lineCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodLineCode"),
      layout: 12,
      required: false
    },
    lineName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodLineName"),
      layout: 12,
      required: false
    },
    processCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.processCode"),
      layout: 12,
      required: false
    },
    processName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.processName"),
      layout: 12,
      required: false
    },
    cellCode: {
      type: "input",
      label: $i18n.t("common.workCellCode"),
      layout: 12,
      required: false
    },
    cellName: {
      type: "input",
      label: $i18n.t("common.workCellName"),
      layout: 12,
      required: false
    },
    teamCode: {
      type: "input",
      label: $i18n.t("common.teamCode"),
      layout: 12,
      required: false
    },
    teamName: {
      type: "input",
      label: $i18n.t("common.teamName"),
      layout: 12,
      required: false
    },
    shiftCode: {
      type: "input",
      label: $i18n.t("common.shiftCode"),
      layout: 12,
      required: false
    },
    shiftName: {
      type: "input",
      label: $i18n.t("common.shiftName"),
      layout: 12,
      required: false
    },
    userBy: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.userBy"),
      layout: 12,
      required: false
    },
    userByName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.userByName"),
      layout: 12,
      required: false
    },
    scanTime: {
      type: "datetime",
      label: $i18n.t("mesScrapMaterial.scanTime"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss"
      }
    },
    planCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodOrderCode"),
      layout: 12,
      required: false
    },
    orderCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodWorkOrderCode"),
      layout: 12,
      required: false
    },
    prodCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodCode"),
      layout: 12,
      required: false
    },
    prodName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.prodName"),
      layout: 12,
      required: false
    },
    seriesCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.seriesCode"),
      layout: 12,
      required: false
    },
    seriesName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.seriesName"),
      layout: 12,
      required: false
    },
    equipmentCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.equipmentCode"),
      layout: 12,
      required: false
    },
    equipmentName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.equipmentName"),
      layout: 12,
      required: false
    },
    scanType: {
      type: "select",
      label: $i18n.t("mesScrapMaterial.scanType"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getScanTypeList()
        return list.data.result
      }
    },
    faultCode: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.faultCode"),
      layout: 12,
      required: false
    },
    faultName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.faultName"),
      layout: 12,
      required: false
    },
    quantity: {
      type: "number",
      label: $i18n.t("mesScrapMaterial.scrapCount"),
      layout: 12,
      required: false
    },
    goodsTypeKey: {
      type: "select",
      label: $i18n.t("mesScrapMaterial.goodsTypeKey"),
      layout: 12,
      required: false,
      prop: {
        value: "value",
        text: "description"
      },
      options: async (data) => {
        const list = await getGoodsTypeList()
        return list.data.result
      }
    },
    reviewBy: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.reviewBy"),
      layout: 12,
      required: false
    },
    reviewByName: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.reviewByName"),
      layout: 12,
      required: false
    },
    reviewTime: {
      type: "datetime",
      label: $i18n.t("mesScrapMaterial.reviewTime"),
      layout: 12,
      required: false,
      attrs: {
        valueFormat: "yyyy-MM-dd HH:mm:ss"
      }
    },
    remark: {
      type: "input",
      label: $i18n.t("common.remark"),
      layout: 12,
      required: false
    }
  }
}
//导入数据
export const importFormDescDialog = {
  span: 24,
  disabled: false,
  isShowSubmitBtn: true,
  formDesc: {
    model: {
      type: "button",
      label: "",//$i18n.t("mesScrapMaterial.model"),
      layout: 24,
      required: false,
      title: $i18n.t('common.downloadTemplate'),
      style: {
        color: "#1867c0",
        fontSize: "14px"
      },
      on: {
        click: () => {
          exportExcel(downloadTemplateUrl)
        }
      }
    },
    file: {
      type: "input",
      label: $i18n.t("mesScrapMaterial.file"),
      layout: 24
      // required: true,
    }
  }
}
